<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="../assets/css/yui-cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="shortcut icon" type="image/x-icon" href="../assets/favicon.ico">
    <script src="../assets/js/yui-source.js"></script>
	<title>SoundJS v1.0.0 API Documentation : soundjs/data/AudioSprite.js</title>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
            
                <h1><a href="http://createjs.site/soundjs"><img src="../assets/docs-icon-SoundJS.png" title="SoundJS"></a></h1>
            
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Documentation for: 1.0.0</em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
    <h2 class="off-left">APIs</h2>
    <div id="api-tabview" class="tabview">
        <ul class="tabs">
            <li><a href="#api-classes">Classes</a></li>
        </ul>

        <div id="api-tabview-filter">
            <input type="search" id="api-filter" placeholder="Type to filter APIs">
        </div>

        <div id="api-tabview-panel">
            <ul id="api-classes" class="apis classes">
            
                <li><a href="../classes/AbstractPlugin.html">AbstractPlugin</a></li>
            
                <li><a href="../classes/AbstractSoundInstance.html">AbstractSoundInstance</a></li>
            
                <li><a href="../classes/AudioSprite.html">AudioSprite</a></li>
            
                <li><a href="../classes/CordovaAudioLoader.html">CordovaAudioLoader</a></li>
            
                <li><a href="../classes/CordovaAudioPlugin.html">CordovaAudioPlugin</a></li>
            
                <li><a href="../classes/CordovaAudioSoundInstance.html">CordovaAudioSoundInstance</a></li>
            
                <li><a href="../classes/ErrorEvent.html">ErrorEvent</a></li>
            
                <li><a href="../classes/Event.html">Event</a></li>
            
                <li><a href="../classes/EventDispatcher.html">EventDispatcher</a></li>
            
                <li><a href="../classes/FlashAudioLoader.html">FlashAudioLoader</a></li>
            
                <li><a href="../classes/FlashAudioPlugin.html">FlashAudioPlugin</a></li>
            
                <li><a href="../classes/FlashAudioSoundInstance.html">FlashAudioSoundInstance</a></li>
            
                <li><a href="../classes/HTMLAudioPlugin.html">HTMLAudioPlugin</a></li>
            
                <li><a href="../classes/HTMLAudioSoundInstance.html">HTMLAudioSoundInstance</a></li>
            
                <li><a href="../classes/HTMLAudioTagPool.html">HTMLAudioTagPool</a></li>
            
                <li><a href="../classes/PlayPropsConfig.html">PlayPropsConfig</a></li>
            
                <li><a href="../classes/Sound.html">Sound</a></li>
            
                <li><a href="../classes/SoundJS.html">SoundJS</a></li>
            
                <li><a href="../classes/Utility Methods.html">Utility Methods</a></li>
            
                <li><a href="../classes/WebAudioLoader.html">WebAudioLoader</a></li>
            
                <li><a href="../classes/WebAudioPlugin.html">WebAudioPlugin</a></li>
            
                <li><a href="../classes/WebAudioSoundInstance.html">WebAudioSoundInstance</a></li>
            
            </ul>

            <ul id="api-modules" class="apis modules">
            
                <li><a href="../modules/CreateJS.html">CreateJS</a></li>
            
                <li><a href="../modules/SoundJS.html">SoundJS</a></li>
            
            </ul>
        </div>
    </div>
</div>

            </div>
        </div>
        <div class="yui3-u-3-4">
            <div id="api-options">
        Show:
        <label for="api-show-inherited">
            <input type="checkbox" id="api-show-inherited" checked>
            Inherited
        </label>

        <label for="api-show-protected">
            <input type="checkbox" id="api-show-protected">
            Protected
        </label>

        <label for="api-show-private">
            <input type="checkbox" id="api-show-private">
            Private
        </label>
        <label for="api-show-deprecated">
            <input type="checkbox" id="api-show-deprecated">
            Deprecated
        </label>

    </div>
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content source-content">
                        <script>
	var name = soundjs/data/AudioSprite.js      
</script>
<h1 class="file-heading">File:AudioSprite.js</h1>

<div class="file">
    <pre class="code prettyprint linenums">
//  NOTE this is &quot;Class&quot; is purely to document audioSprite Setup and usage.
/**
 * @module SoundJS
 */

/**
 * &lt;strong&gt;Note: AudioSprite is not a class, but its usage is easily lost in the documentation, so it has been called
 * out here for quick reference.&lt;/strong&gt;
 *
 * Audio sprites are much like CSS sprites or image sprite sheets: multiple audio assets grouped into a single file.
 * Audio sprites work around limitations in certain browsers, where only a single sound can be loaded and played at a
 * time. We recommend at least 300ms of silence between audio clips to deal with HTML audio tag inaccuracy, and to prevent
 * accidentally playing bits of the neighbouring clips.
 *
 * &lt;strong&gt;Benefits of Audio Sprites:&lt;/strong&gt;
 * &lt;ul&gt;
 *     &lt;li&gt;More robust support for older browsers and devices that only allow a single audio instance, such as iOS 5.&lt;/li&gt;
 *     &lt;li&gt;They provide a work around for the Internet Explorer 9 audio tag limit, which restricts how many different
 *     sounds that could be loaded at once.&lt;/li&gt;
 *     &lt;li&gt;Faster loading by only requiring a single network request for several sounds, especially on mobile devices
 * where the network round trip for each file can add significant latency.&lt;/li&gt;
 * &lt;/ul&gt;
 *
 * &lt;strong&gt;Drawbacks of Audio Sprites&lt;/strong&gt;
 * &lt;ul&gt;
 *     &lt;li&gt;No guarantee of smooth looping when using HTML or Flash audio. If you have a track that needs to loop
 * 		smoothly and you are supporting non-web audio browsers, do not use audio sprites for that sound if you can avoid
 * 		it.&lt;/li&gt;
 *     &lt;li&gt;No guarantee that HTML audio will play back immediately, especially the first time. In some browsers
 *     (Chrome!), HTML audio will only load enough to play through at the current download speed – so we rely on the
 *     &#x60;canplaythrough&#x60; event to determine if the audio is loaded. Since audio sprites must jump ahead to play specific
 *     sounds, the audio may not yet have downloaded fully.&lt;/li&gt;
 *     &lt;li&gt;Audio sprites share the same core source, so if you have a sprite with 5 sounds and are limited to 2
 * 		concurrently playing instances, you can only play 2 of the sounds at the same time.&lt;/li&gt;
 * &lt;/ul&gt;
 *
 * &lt;h4&gt;Example&lt;/h4&gt;
 *
 *		createjs.Sound.initializeDefaultPlugins();
 *		var assetsPath = &quot;./assets/&quot;;
 *		var sounds = [{
 *			src:&quot;MyAudioSprite.ogg&quot;, data: {
 *				audioSprite: [
 *					{id:&quot;sound1&quot;, startTime:0, duration:500},
 *					{id:&quot;sound2&quot;, startTime:1000, duration:400},
 *					{id:&quot;sound3&quot;, startTime:1700, duration: 1000}
 *				]}
 *			}
 *		];
 *		createjs.Sound.alternateExtensions = [&quot;mp3&quot;];
 *		createjs.Sound.on(&quot;fileload&quot;, loadSound);
 *		createjs.Sound.registerSounds(sounds, assetsPath);
 *		// after load is complete
 *		createjs.Sound.play(&quot;sound2&quot;);
 *
 * You can also create audio sprites on the fly by setting the startTime and duration when creating an new AbstractSoundInstance.
 *
 * 		createjs.Sound.play(&quot;MyAudioSprite&quot;, {startTime: 1000, duration: 400});
 *
 * The excellent CreateJS community has created a tool to create audio sprites, available at
 * &lt;a href=&quot;https://github.com/tonistiigi/audiosprite&quot; target=&quot;_blank&quot;&gt;https://github.com/tonistiigi/audiosprite&lt;/a&gt;,
 * as well as a &lt;a href=&quot;http://jsfiddle.net/bharat_battu/g8fFP/12/&quot; target=&quot;_blank&quot;&gt;jsfiddle&lt;/a&gt; to convert the output
 * to SoundJS format.
 *
 * @class AudioSprite
 * @since 0.6.0
 */

    </pre>
</div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
